﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>分享</title>
    <!-- Bootstrap -->
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet">
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="/CSS/Base/BaseClass.css?cssver=4" rel="stylesheet">

    <style>
        .logo .comName {
            height: 26px;
            line-height: 26px;
            overflow: hidden;
            word-wrap: break-word;
            word-break: break-all;
            display: inline-block;
            margin-bottom: -8px;
            font-size: 26px;
            color: #fff;
            margin-top: 0px;
            position: absolute;
            left: 100px;
            top: 30px;
        }


        .modal-backdrop {
            background-color: black;
        }
    </style>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body style="background-color:white" ms-controller="APP_QYWD_View">
    <div id="topdv" style=" height: 88px; background-image: url(/images/Index/top_bg.png)" class="colorBg3">
        <div class="logo">
            <span class="comName"> 北京神州互联科技有限公司</span>
        </div>
    </div>

    <div style="width:250px;position:absolute; margin:20px 0 0 20px">
        <div class="box">
            <div class="box-content text-center nopard">
                <img alt="image" class="img-rounded" onerror="javascript: this.src = '/images/TX/default.png'" ms-attr-src="'/Upload/TX/'+fxuser+'.jpg'" style="width:65px;height:65px;margin-top:5px;" onerror="javascript: this.src = '/images/TX/default.png'">
                <div style="padding:0 10px 5px 10px">
                    <address style="margin-bottom:0">
                        <strong>分享人</strong><br>
                        {{fxuser}}
                    </address>
                </div>
            </div>
        </div>
    </div>
    <div class="row" style="margin:20px 0 0 271px">
        <div></div>
        <div class="col-xs-11">
            <div class="panel panel-default">
                <div class="panel-heading">分享内容
                    <div class="btn-group" role="group" ms-if="SelItemData.size()>0" style="margin-left:10px">
                        <button ms-click="downloaditem()" type="button" class="btn btn-default "><i class="fa fa-download"></i>&nbsp;下载</button>
                    </div>
                </div>
                <div class="panel-body">
                    <ol class="breadcrumb" style="margin-bottom:0;font-weight:bold;background-color:white">
                        <li ms-click="enterfolder()"><a href="#">分享文件</a></li>

                        <li ms-repeat-path="Pathdata" ms-class="active:path.active" ms-click="gopath(path)"><a href="#">{{path.Name}}</a></li>
                    </ol>
                    <ul class="listContent">
                        <li class="lifile" ms-repeat-item="ListData" ms-class-1="selli:item.issel" ms-attr-itemtype="item.type" ms-on-mousedown="filecontextmenu(item,event)" data-repeat-rendered="filechange" ms-on-dblclick="viewitem(item,$(this))" ms-attr-title="item.CRDate">
                            <i ms-click="selItems(item,event)" class="fa" ms-class-1="fa-square-o:!item.issel" ms-class-2="fa-check-square:item.issel"></i>
                            <img class="fileimg" ms-click="selItem(item,event)" ms-src="/images/NewIndex/qywd/{{item.type=='folder'?'file1':item.FileExtendName}}.png"  onerror="javascript: this.src = '/images/NewIndex/qywd/file.png'">
                            <input type=" text" ms-attr-value="item.Name" style="width:80px;border:0;background-color:transparent" />
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="codemoadl" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">输入访问码</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <input type="text" class="form-control" id="concode" ms-keypress="jptj(event,$(this))" placeholder="此处输入访问码,按下CTRL+ENTER即可" />
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-success" ms-click="enterfolder()"><i class="fa fa-spinner fa-spin" style="display:none"></i> 确&nbsp;&nbsp;认</button>
                </div>
            </div>
        </div>
    </div>

    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/JqueryPlug/layer/layer/lay.js"></script>

    <script src="/Scripts/avalon.min.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script>
        var model = avalon.define({
            $id: "APP_QYWD_View",
            sharecode: ComFunJS.getQueryString("code"),
            ListData: [],
            fxuser:"",
            Pathdata: [],
            gopath: function (path) {
                model.GetListData(path.ID);
                for (i = model.Pathdata.size() - 1; i >= 0; i--) {
                    if (model.Pathdata[i].ID != path.ID) {
                        model.Pathdata.pop(model.Pathdata[i])
                    } else {
                        model.Pathdata[i].active = true;
                        return;
                    }
                }

            },//目录链接
            viewitem: function (item, dom) {
                if (item.type == "folder") {
                    model.GetListData(item.ID)
                    var newpath = item.$model;
                    model.Pathdata.forEach(function (path) {
                        path.active = false;
                    })
                    newpath.active = true;
                    model.Pathdata.push(newpath)
                }
                else {
                    alert(item.Name)
                }

            },
            downloaditem: function () {
                if (model.SelItemData.size() == 1 && model.SelItemData[0].type == "file") {
                    ComFunJS.winold("/View/Common/DownLoadFile.aspx?MD5=" + model.SelItemData[0].FileMD5)
                } else {
                    var code = "";
                    model.SelItemData.forEach(function (item) {
                        code = code + item.ID + "|" + item.type + ",";
                    })
                    if (code.length > 1) {
                        code = code.substring(0, code.length - 1)
                    }
                    parent.ComFunJS.winviewform("/View/Common/DownFolder.html?code=" + code, "下载文件", "550", "450")
                }
            },
            selItems: function (item, event) {
                item.issel = !item.issel;
                if (item.issel) {
                    model.SelItemData.push(item)
                } else {
                    model.SelItemData.remove(item)
                }
                event.stopPropagation();
            },//多选
            selItem: function (item, event) {
                model.ListData.forEach(function (el) {
                    el.issel = item.ID == el.ID;
                })
                model.SelItemData.clear();
                model.SelItemData.push(item)

            },//单选
            SelItemData: [],//已选中列表
            GetListData: function (PID) {
                $.getJSON('/API/CommAPI.ashx?Action=GETSHARELIST', { P1: PID }, function (resultData) {//P1为个人文件夹
                    if (resultData.ErrorMsg == "") {
                        resultData.Result.forEach(function (item) {
                            item.issel = false;
                            item.type = "folder";
                        })
                        resultData.Result1.forEach(function (item) {
                            item.issel = false;
                            item.type = "file";
                        })
                        model.ListData = resultData.Result.concat(resultData.Result1);
                        model.SelItemData.clear();
                    }
                })
            },//获取目录及文件
            enterfolder: function () {
                if ($("#concode").val() != "") {
                    $.getJSON('/API/CommAPI.ashx?Action=GETFOLDERBYCODE', { P1: model.sharecode, P2: $("#concode").val() }, function (resultData) {//P1为个人文件夹
                        if (resultData.ErrorMsg == "") {
                            resultData.Result.forEach(function (item) {
                                item.issel = false;
                                item.type = "folder";
                            })
                            resultData.Result1.forEach(function (item) {
                                item.issel = false;
                                item.type = "file";
                            })
                            model.ListData = resultData.Result.concat(resultData.Result1);
                            model.SelItemData.clear();
                            if (model.ListData.size() > 0) {
                                $('#codemoadl').modal('hide')
                                model.Pathdata.clear();
                                model.fxuser = model.ListData[0].CRUser;
                            } else {
                                alert("不存在分享文件,请检查分享链接或提取码是否正确")
                            }
                            
                        }
                    })
                } else {
                    alert("提取码不能为空！")
                }

            }
        })
        avalon.ready(function () {
            ComFunJS.initsetajax();
            // model.GetListData(2);
            $('#codemoadl').modal({
                keyboard: false
            })
            $('#codemoadl').on('hide.bs.modal', function (e) {
                if (model.ListData.size() == 0) {
                    return false;
                }
            })


        })
    </script>
</body>
</html>